package com.qianxun.Test.BaseTest;



import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Base64;

public class TestBase64 {
    public static void main(String[] args){
        String encode=TestBase64.TestEncoder("12345ghfgh6");
        System.out.println(encode);
        String decode = TestBase64.TestDecoder(encode);
        System.err.println(decode);
    }
    public static String TestEncoder(String demoString){
        Base64.Encoder encoder = Base64.getEncoder();
        byte [] bt = new byte[0];
        try {
            InputStream inputStream = new FileInputStream("0");
           bt=demoString.getBytes("UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
       return encoder.encodeToString(bt);
    }
    public static String TestDecoder(String demoString){
        String test = null;
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] decode = decoder.decode(demoString);
        try {
           test= new String(decode,"UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return test;
    }
}
